package com.tuomaxu.servlet;

import com.tuomaxu.pojo.Request;
import com.tuomaxu.pojo.Response;

import java.io.IOException;

public abstract class HttpServlet implements Servlet{

    abstract public void doGet(Request request, Response response) throws IOException;
    abstract public void doPost(Request request, Response response) throws IOException;

    public HttpServlet() {
    }

    @Override
    public void service(Request request, Response response) {
        try {
            if(request.getMethod().equalsIgnoreCase("get")){
                doGet(request,response);
            }

            if(request.getMethod().equalsIgnoreCase("post")){
                doPost(request,response);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
